/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.ufc.contoller;

import br.com.ufc.exception.BusinessException;
import br.com.ufc.exception.IntegrationException;
import br.com.ufc.model.Tarefa;
import br.com.ufc.model.TarefaDataBase;
import br.com.ufc.model.TarefaTO;
import br.com.ufc.model.data.TarefaPersistence;
import java.util.logging.Logger;

/**
 * Classe que define o objeto agenda que manipula dados vindos do banco de dados
 * @author Paulo
 */
public class AgendaDataBase implements Agendavel {

    private static TarefaPersistence tp;

    static {
        tp = new TarefaPersistence();
    }

    /**
     * Metodo faz uma chamada ao DAO para uma consulta
     * @param codigo
     * @return
     * @throws IntegrationException 
     */
    public TarefaDataBase consultarTarefa(Long codigo) throws IntegrationException {
        return tp.consultarTarefa(codigo);
    }

    public TarefaTO listarTarefas() {
        TarefaPersistence tp = new TarefaPersistence();
        return tp.listarTarefas();
    }

    public Boolean cadastrarTarefa(String data, String descricao,
            Integer duracao, String horaInicio, Integer importancia,
            String local, String status, Integer urgencia,
            Double valorCobrado, Double valorHora) throws IntegrationException{
        TarefaDataBase tarefa = new TarefaDataBase(data, descricao, duracao,
                horaInicio, importancia, local, status, urgencia, valorCobrado,
                valorHora);
        return cadastrarTarefa(tarefa);
    }

    public Boolean cadastrarTarefa(Tarefa tarefa) {
        try {
            return tp.inserirTarefa((TarefaDataBase)tarefa);
        } catch (IntegrationException ex) {
            Logger.getLogger(ex.getLocalizedMessage());
        }
        return null;
    }

    public Boolean removerTarefa(TarefaDataBase tarefa) throws IntegrationException {
        return tp.deletarTarefa(tarefa);
    }

    public Tarefa consultarTarefaPorCodigo(Long codigo) throws IntegrationException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Boolean encerrarTodasTarefas() {
        return tp.encerrarTodasTarefas();
    }

    public Boolean encerrarTarefa(Tarefa t, Double valorCobrado) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void encerrarTarefa(Long codigo, Double valorCobrado) throws IntegrationException {
        tp.encerrarTarefa(codigo, valorCobrado);
    }
       

    public void cancelarTarefa(Long codigo) throws IntegrationException {
        tp.cancelarTarefa(codigo);
    }

    public Boolean removerTarefa(Tarefa t) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void removerTarefa(Long codigo) throws IntegrationException {
        tp.removerTarefa(codigo);
    }
    
    public Boolean iniciarTarefa(Tarefa t) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void iniciarTarefa(Long codigo) throws IntegrationException {
        tp.iniciarTarefa(codigo);
    }

    public Boolean cancelarTarefa(Tarefa t) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Boolean reiniciarTarefa(Tarefa t) throws BusinessException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void reiniciarTarefa(Long codigo) throws IntegrationException {
        tp.reiniciarTarefa(codigo);
    }

    public void incrementarImportancia(Tarefa t) {
        tp.incrementarImportancia(t);
    }

    public void setTarefas(Integer tamanhoArray) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
